package com.czk.scope;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.stereotype.Component;

/**
 * 将新定义的Scope注入到spring容器中
 *
 * @Author:ChenZhangKun
 * @Date: 2021/4/28 15:27
 */
@Component
public class ThreadLocalBeanFactoryPostProcessor implements BeanFactoryPostProcessor {
    @Override
    public void postProcessBeanFactory(ConfigurableListableBeanFactory configurableListableBeanFactory) throws BeansException {
        // 注入scope中
        configurableListableBeanFactory.registerScope("threadScope", new ThreadScope());
    }
}
